package com.orifine.orm.information;

import com.orifine.orm.Information;
import com.orifine.orm.model.ColumnModel;

public class AutoIncrementInfo implements Information {
	private int beginNum = 1;
	private int increment = 1;
	
	public AutoIncrementInfo(){
		
	}
	
	public AutoIncrementInfo(int beginNum, int increment){
		this.beginNum = beginNum;
		this.increment = increment;
	}
	
	@Override
	public Object value(int index, ColumnModel columnMapper) {
		return beginNum + index*increment;
	}

	@Override
	public void init(ColumnModel columnModel) {
		if(columnModel.isAutoIncrement() == null){
			columnModel.setAutoIncrement(true);
		}
	}
}
